/*
 * EnChargeFaceObstacle.cpp
 *
 *  Created on: 12 nov. 2012
 *      Author: guegan
 */

#include "EnChargeFaceObstacle.h"

EnChargeFaceObstacle* EnChargeFaceObstacle::_instance;

void EnChargeFaceObstacle::tourner(string direction) {
	if (!(direction == "N" || direction == "E" || direction == "O" || direction == "S"))
		throw EtatRobot::TournerException();

	robot->setEtatRobot(EtatRobot::getEtatRobot("EnCharge"));

	robot->setDirection(direction);

	if( robot->getObstacle() != NULL )
		robot->setObstacle(NULL);
}

int EnChargeFaceObstacle::peser() {
	return robot->getObjet()->getPoids();
}

void EnChargeFaceObstacle::poser() {
	robot->setEtatRobot(EtatRobot::getEtatRobot("aVideFaceObstacle"));

	robot->setObjet(NULL);
}

EnChargeFaceObstacle* EnChargeFaceObstacle::instance() {
    if(_instance == NULL)
          _instance = new EnChargeFaceObstacle("EnChargeFaceObstacle");

    return _instance;
}

EnChargeFaceObstacle::~EnChargeFaceObstacle() {
	_instance = NULL;
}
